Title Banner


Technotes


Control Manager Q&As



Technote TB 510October 1990



Revised by: Developer Support Center September 1993
Written by: Developer Support Center October 1990

This Technical Note contains a collection of archived Q&As relating to a specific topic--questions sent the Developer Support Center (DSC) along with answers from the DSC engineers. Current Q&A's can be found on the Macintosh Technical Q&A's web site.


Color with Macintosh radio button and check box controls

Date Written: 6/11/91

Last reviewed: 8/1/92

I can control the color of a Macintosh radio button and its accompanying text using a control color table, but I am not able to exercise much control over the color of the background rectangle. Let's say, for example, that I create a window whose content area is gray (using SetWinColor). Within the window, I draw a black box, and within the black box, I draw a pair of radiobuttons whose text color is white. I would like the background rectangles of the radiobuttons to be black so that they will match the color of the box. Unfortunately, using Draw1Control, the Control Manager seems to draw the background rectangle using the content color of the window (in this case, gray). Is there any easy way to get around this? (Calls to RGBForeColor and RGBBackColor seem to have no effect during Draw1Control.)

___

The explanation for the problems you are having is very simple. Standard check boxes and radio buttons use the window content color for their background. This is by design since the text of the button is not bounded by anything. Here are two resolutions to your problem: You can simply set your window background to the background you want the button to have, or you can write your own 'CDEF' to handle buttons and have it use the control's background color instead of the window's content color. You'll find sample code that does this in the Snippets folder on AppleLink and the latest Developer CDs.

Changing a Macintosh control's variant

Date Written: 10/3/91

Last reviewed: 6/14/93

What is the proper method to set a control's variant field, if there's no SetCVariant trap?

___

There is no way to set the Variant field of a control from the toolbox. Standard controls do not support the dynamic modification of the variant field; they are not tested for this and an undefined error could result. As for custom controls, if you need to change a variant midway through the control's use, it's better not to use the variant field at all, but instead to store your own data structure in the ctrlData field to track what type of control you are drawing. The reason for this is that the variant field is not always in the same place. The only time it is in a well-defined place is when you are operating in 24-bit mode (then it is stored in the high byte of the controls defproc handle, as documented in Inside Macintosh Volume I). When you are in 32-bit mode, it is stored in the AuxCtlRec in a private location.(high byte of the Reserved field right now, but that can change in an instant...)




Tech Support
Technotes
Previous Technote | Contents | Next Technote


Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help